#!/bin/sh

load_config() {
    local file=$1
    CONFIG=$(cat ${file})
    if [ $? -ne 0 ]; then
        echo -e "\033[31m无法加载配置文件。\033[0m"
        exit 1
    fi
}

getenv() {
    if [ -z "${CONFIG}" ]; then
        load_config /etc/idnewnil/config.json
    fi
    echo ${CONFIG} | jq "$@"
}

getstr() {
    local string=$(getenv "$@")
    echo ${string:1:-1}
}
